package olap4cloud.hbase;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Callable;

import org.apache.hadoop.hbase.client.HTable;
import org.apache.hadoop.hbase.client.HTableInterface;
import org.apache.hadoop.hbase.client.Increment;
import org.apache.hadoop.hbase.client.Put;
import org.apache.log4j.Logger;

public class TaskPutDataInToDB implements Callable{
	
	private static Logger logger = Logger.getLogger("Batch");
    /**
	 * @uml.property  name="htable"
	 * @uml.associationEnd  multiplicity="(0 -1)" elementType="org.apache.hadoop.hbase.client.Put"
	 */
    private HTableInterface htable;
	//HTable htable;
    /**
	 * @uml.property  name="listPut"
	 * @uml.associationEnd  multiplicity="(0 -1)" elementType="org.apache.hadoop.hbase.client.Put"
	 */
    private List<Put> listPut = new ArrayList<Put>();
        
    public TaskPutDataInToDB ( HTableInterface htable , List<Put> listPut){
    	//this.htable = htable;
    	this.htable = htable;
    	this.listPut.addAll(listPut);
    	this.htable.setAutoFlush(false);
    }
    
	@Override
	public Object call() throws Exception {
		// TODO Auto-generated method stub
		htable.put(listPut);
		htable.flushCommits();
		return null;
	}
}
